package com.example.backspring.Service.impl;

import com.example.backspring.Service.StudentService;
import com.example.backspring.config.GetUUID;
import com.example.backspring.config.Message;
import com.example.backspring.dao.StudentMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class StudentServiceImpl implements StudentService {
    @Resource
    private StudentMapper studentMapper;

    @Override
    public String RegisteUser(String username, String pwd) {
       String tid= GetUUID.generateShortUuid();
        studentMapper.add(tid.toString(),username, pwd);
        return "注册成功";
    }

    @Override
    public Message Login(String username, String pwd) {
      int res=  studentMapper.login(username,pwd);
        Message result=new Message();
        if (res==1){
            result.setSuccess(true);
            result.setMessage("登录成功");
            result.setStatus(1);
        }else {
            result.setSuccess(false);
            result.setMessage("用户名或者密码错误");
            result.setStatus(0);
        }
        return result;
    }
}
